//================= config =================
var ENCRYPTION_KEY = "adsl@1234";
//username,password,uniqueId,isWorking,leaves,currentDate,latestTime,pastTime,totalTime,leftTime
var KEY_HE_DATA = "heLeaveData";
var URL_GET_UNIQUE_ID = "http://leave.happyelements.net/index.php?controller=application&action=add";
var DUTY_HOURS = 9;
var EXCELLENT_HOURS = 12;
var WORK_HOUR_INTERVAL = 1;

//================= common =================
function trace(){
	var moduleName = arguments[0], msg = arguments[1];
	var str = "G4S ";
	str += "at[";
	str += moduleName;
	str += "]-->";
	if(window && window.console && window.console.log){
		window.console.log(str, msg);
	}
}

function setPara(url,name,value){
	//TODO trim splace
	// url = $.trim(url);
	var paras = name + "=" + value;
	var v = getPara(url, name);
	return v == "" ? (url + ((url.indexOf("?")<0) ? "?" : "&") + paras) : url.replace("&"+name+"="+v,"&"+paras).replace("?"+name+"="+v,"?"+paras);
};

function getPara(url, name){
	var str = '',_p = name + '=';
	var url = url ? url.split("#")[0] : "";
	if(url.indexOf("&"+_p)>-1) str = url.split("&"+_p)[1].split("&")[0];
	if(url.indexOf("?"+_p)>-1) str = url.split("?"+_p)[1].split("&")[0];
	return str;
};

function getToday(){
	var date = new Date();
	var today = [date.getFullYear(), date.getMonth() + 1, date.getDate()].join("-");
	return today;
};

function getMonth(){
	var date = new Date();
	var today = [date.getFullYear(), date.getMonth() + 1].join("-");
	return today;
};

//================= localStorage =================
function setLocalData(obj, key){
	if(!key){
		key = "_ibio_default_key";
	}
	if(obj){
		localStorage[key] = JSON.stringify(obj);
	}
}

function getLocalData(key){
	if(!key){
		key = "_ibio_default_key";
	}
	var obj;
	try{
		obj = localStorage[key] ? JSON.parse(localStorage[key]) : null;
	}catch(e){
		//
	}
	return obj;
}

function removeLocalData(key){
	if(key){
		localStorage.removeItem(key);
	}else{
		localStorage.clear();
	}
}